package com.snake.springboot.authority.service.assembler;

import com.snake.springboot.authority.api.model.AuthModuleModel;
import com.snake.springboot.authority.dao.mybatis.entity.AuthModuleDO;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.utils.PropertyUtils;

/**
 * 类 {@code AuthModuleAssembler}  <br> .
 * <p>系统模块组装器
 * 创建时间：2024/5/27 14:29
 *
 * @author Yzhui
 * @see
 */
public class AuthModuleAssembler {

    public static AuthModuleDO assembleAuthModuleDO(AuthModuleModel model, boolean isNew) throws Exception {
        AuthModuleDO entity = new AuthModuleDO();
        PropertyUtils.copyPropertiesIfNull(entity, model);
        if(isNew) {
            SerialNumberGeneratorFactory.buildId4Bean(entity, "moduleId");
        }
        return entity;
    }


    public static AuthModuleModel assembleAuthModuleModel(AuthModuleDO entity){
        AuthModuleModel model = new AuthModuleModel();
        PropertyUtils.copyPropertiesIfNull(model, entity);
        return model;
    }
}
